<template>
  <div class="login-wrap">
    <el-form
      class="login-form"
      label-position="top"
      label-width="80px"
      :model="formdata"
    >
      <h2>管理员登录</h2>
      <el-form-item label="用户名">
        <el-input v-model="formdata.username"></el-input>
      </el-form-item>
      <el-form-item label="密码">
        <el-input v-model="formdata.password"></el-input>
      </el-form-item>
      <el-button class="login-btn" type="primary" @click="login">登录</el-button>
      <br /> <br />
      <el-button class="login-btn" type="primary" @click="faceLogin">人脸登录</el-button>
    </el-form>
  </div>
</template>

<script>
  import axios from 'axios';
  export default {
    name: "Login",
    data() {
      return {
        formdata: {
          username: "",
          password: "",
        },
      };
    },
    methods:{
      login(){
        axios.post("http://localhost:8100/login",this.formdata).then(res=>{
          if (res.data.state){
            alert(res.data.message);
            this.$router.push("/user")
          } else {
            alert(res.data.message);
            this.formdata = '';
            this.$router.push("/")
          }

        })
      },
      faceLogin(){
        window.location.href="http://localhost:9876/login/jumpGetface"
        // 华为云服务器人脸识别地址
        // window.location.href="http://121.37.128.160:9876/login/jumpGetface"


      }

    }
  };
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
  .login-wrap {
    height: 100%;
    background: #324152;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .login-form {
    width: 400px;
    background: #fff;
    border-radius: 5px;
    padding: 30px;
  }
  .login-btn {
    width: 100%;
  }
</style>
